<form action="index.php" method="post" name="adminForm" id="adminForm">
<script type="text/javascript">
jQuery(document).ready(
  function(){
    <? if(!isset($this->stat)): ?>
      jQuery('#team_id').change();
    <? endif; ?>
    jQuery("#adminForm").validate({
      rules:  {
        field_goals:{
          required: true,
          digits: true
        },
        field_goal_attempts:{
          required: true,
          digits: true
        },
        three_points:{
          required: true,
          digits: true
        },
        three_point_attempts:{
          required: true,
          digits: true
        },
        free_throws:{
          required: true,
          digits: true
        },
        free_throw_attempts:{
          required: true,
          digits: true
        },
        off_rebounds:{
          required: true,
          digits: true
        },
        def_rebounds:{
          required: true,
          digits: true
        },
        assists:{
          required: true,
          digits: true
        },
        steals:{
          required: true,
          digits: true
        },
        blocks:{
          required: true,
          digits: true
        }
      }
    });
  }
);
</script>
  <fieldset class="adminform">
    <legend>Details</legend>
      <?
        $id                  = 0;
        $schedule_id         = null;
        $player_id           = null;
        $points              = null;
        $field_goals         = null;
        $field_goal_attempts = null;
        $three_points        = null;
        $three_point_attempts= null;
        $free_throws         = null;
        $free_throw_attempts = null;
        $off_rebounds        = null;
        $def_rebounds        = null;
        $assists             = null;
        $steals              = null;
        $blocks              = null;
        $published           = true;
        
        $schedules           = array();
        $players             = array();
        $teams               = array();
        
        if(isset($this->stat)){
          $id                = $this->stat->id;
          $schedule_id       = $this->stat->schedule_id;
          $player_id         = $this->stat->player_id;
          $points            = $this->stat->points;
          $field_goals       = $this->stat->field_goals;
          $field_goal_attempts  = $this->stat->field_goal_attempts;
          $three_points      = $this->stat->three_points;
          $three_point_attempts = $this->stat->three_point_attempts;
          $free_throws       = $this->stat->free_throws;
          $free_throw_attempts  = $this->stat->free_throw_attempts;
          $off_rebounds      = $this->stat->off_rebounds;
          $def_rebounds      = $this->stat->def_rebounds;
          $assists           = $this->stat->assists;
          $steals            = $this->stat->steals;
          $blocks            = $this->stat->blocks;
          $published         = $this->stat->published;
        }
        
        if(isset($this->schedules))
          $schedules = $this->schedules;
        
        if(isset($this->players))
          $players = $this->players;
          
        if(isset($this->teams))
          $teams = $this->teams;
      ?>
            <table class="admintable">
        <tr style="height:55px">
          <td class="key"><?= JText::_('Select Team:')?></td>
          <td>
            <? 
            $player_link = "ajx_request('".JRequest::getVar('c', 'playergamestat')."', 'ajx_select_players', 'team_id='+this.value , 'div_players');";
            $schedule_link = "onchange=\"ajx_request('teamgamestat', 'ajx_select_scheds', 'team_id='+this.value , 'div_scheds');".
                     $player_link."\""; 
            ?>            
            <?= JHTML::_('select.genericlist', $teams, 'team_id', $schedule_link, 'id', 'name', null); ?>
          </td>
        </tr>
        <tr>
          <td class="key">Schedule</td>
          <td>
            <div id="div_scheds">
            <?= JHTML::_('select.genericlist', $schedules, 'schedule_id', null, 'id', 'schedule', $schedule_id) ?>
            </div>
          </td>
        </tr>
        <tr>
          <td class="key">Player</td>
          <td>
            <div id="div_players">
            <?= JHTML::_('select.genericlist', $players, 'player_id', null, 'id', 'name', $player_id); ?>
            </div>
          </td>
        </tr>
        <tr>
          <td class="key">Points</td>
          <td>
            <input type="text" name="points" id="points" value="<?= $points ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Field Goals</td>
          <td>
            <input type="text" name="field_goals" id="field_goals" value="<?= $field_goals ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Field Goal Attempts</td>
          <td>
            <input type="text" name="field_goal_attempts" id="field_goal_attempts" value="<?= $field_goal_attempts ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">3 Points</td>
          <td>
            <input type="text" name="three_points" id="three_points" value="<?= $three_points ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">3 Point Attempts</td>
          <td>
            <input type="text" name="three_point_attempts" id="three_point_attempts" value="<?= $three_point_attempts ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Free Throws</td>
          <td>
            <input type="text" name="free_throws" id="free_throws" value="<?= $free_throws ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Free Throw Attempts</td>
          <td>
            <input type="text" name="free_throw_attempts" id="free_throw_attempts" value="<?= $free_throw_attempts ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Offensive Rebounds</td>
          <td>
            <input type="text" name="off_rebounds" id="off_rebounds" value="<?= $off_rebounds ?>" />
          </td>
        </tr><tr>
          <td class="key">Defensive Rebounds</td>
          <td>
            <input type="text" name="def_rebounds" id="def_rebounds" value="<?= $def_rebounds ?>" />
          </td>
        </tr><tr>
          <td class="key">Assists</td>
          <td>
            <input type="text" name="assists" id="assists" value="<?= $assists ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Steals</td>
          <td>
            <input type="text" name="steals" id="steals" value="<?= $steals ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Blocks</td>
          <td>
            <input type="text" name="blocks" id="blocks" value="<?= $blocks ?>" />
          </td>
        </tr>
        <tr>
          <td class="key">Published</td>
          <td>
            <?= JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published); ?>
          </td>
        </tr>
             </table>
       </fieldset>
       <input type="hidden" name="option" value="<?= JRequest::getVar( 'option' );?>"/>
     <input type="hidden" name="c" value="<?= JRequest::getVar('c', 'position'); ?>" />
       <input type="hidden" name="id" value="<?= $id; ?>"/>
     <input type="hidden" name="task" value=""/>
</form>
